Currently, the blockchain technology is widely used, and a decentralized mode in the blockchain technology ensures that data is not easily tampered with, thereby improving security.
In practice, a blockchain network that includes multiple nodes (the nodes can be considered as devices in the blockchain network that participate in processing services) can provide corresponding services for client devices. Nodes in the blockchain network perform processing for service requests of the client devices, and feed back processing results to the client devices. In this process, processing results generated by the independently running nodes may be inconsistent. To ensure that the client device can receive a correct processing result, a consensus among the nodes is implemented by using a Practical Byzantine Fault Tolerance (PBFT) algorithm (that is, a correct processing result can be jointly acknowledged or accepted by the nodes).
In a process of using the PBFT algorithm, a consensus is usually performed in a view. In a view, one node in a blockchain network is used as a primary node (primary), and other nodes are used as backup nodes (backup). In this case, the primary node receives a service request of the client device and broadcasts the service request to all the backup nodes, and the primary node initiates a consensus. The nodes that reach the consensus perform processing for the service request and feed back a processing result to the client device.
In the existing technology, a backup node initiates view switching, and the view switching initiated by the backup node usually needs to be acknowledged or accepted by other nodes in the view. The backup node initiates a view switching request to other nodes (including the primary node) in the view, that is, initiates a consensus on the view switching request to other nodes (this consensus still uses PBFT. Different from the process of the consensus on the service request, in a consensus process based on the view switching request, each node suspends the consensus on the service request. Therefore, the consensus on the view switching request is essentially an additional consensus process). After a predetermined quantity of nodes reach a consensus, it is determined that a backup node becomes a new primary node. The new primary node broadcasts a new view message to complete view switching.
However, in the previous mechanism, an additional consensus process needs to be performed for the view switching initiated by the backup node, and the additional consensus process increases a system computation amount. In addition, in the consensus process of view switching, a consensus can be reached after being confirmed by a predetermined quantity of nodes. Finally, a new primary node broadcasts a new view message, and the entire process consumes a period of time. Apparently, an existing view switching way not only increases a computation amount of the system, but also increases time consumed for processing a service request. Consequently, relatively low processing efficiency is caused.